x11: Add gdk_x11_display_set_window_scale
authorAlexander Larsson <alexl@redhat.com>
Tue, 20 Aug 2013 09:15:08 +0000 (11:15 +0200)
committerAlexander Larsson <alexl@redhat.com>
Tue, 20 Aug 2013 09:15:08 +0000 (11:15 +0200)
This lets you force a specific window scale, this is needed
for mutter to be able to disable the scaling as it needs access
to unmangled X window/screen sizes. It can also be useful to
force a specific scale in e.g. tests.

gdk/x11/gdkdisplay-x11.c
gdk/x11/gdkx11display.h

index 575a3b7b03034f0a2649ce09d5c719574522ca6c..e1a28ead401880f793a3d58e3de2357d4ec98ef1 100644 (file)
@@ -2673,6 +2673,43 @@ gdk_x11_display_error_trap_pop_internal (GdkDisplay *display,
   return result;
 }
 
+/**
+ * gdk_x11_display_set_window_scale:
+ * @display: (type GdkX11Display): the display
+ * @scale: The new scale value
+ *
+ * Forces a specific window scale for all windows on this display,
+ * instead of using the default or user configured scale. This
+ * is can be used to disable scaling support by setting @scale to
+ * 1, or to programmatically set the window scale.
+ *
+ * Once the scale is set by this call it will not change in response
+ * to later user configuration changes.
+ *
+ * Since: 3.10
+ */
+void
+gdk_x11_display_set_window_scale (GdkDisplay *display,
+                                  gint scale)
+{
+  GdkX11Screen *x11_screen;
+
+  g_return_if_fail (GDK_IS_X11_DISPLAY (display));
+
+  scale = MAX (scale, 1);
+
+#ifndef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
+  /* Without cairo support we can't support any scale but 1 */
+  scale = 1;
+#endif
+
+  x11_screen = GDK_X11_SCREEN (GDK_X11_DISPLAY (display)->screen);
+
+  x11_screen->fixed_window_scale = TRUE;
+  _gdk_x11_screen_set_window_scale (x11_screen, scale);
+}
+
+
 /**
  * gdk_x11_display_error_trap_pop:
  * @display: (type GdkX11Display): the display
index c4e66ecb7702a7f9406a7a9b06cef752ade21964..703aec7754309df2c29e13640e48d345dfacb589 100644 (file)
@@ -85,6 +85,10 @@ void        gdk_x11_display_grab              (GdkDisplay *display);
 GDK_AVAILABLE_IN_ALL
 void        gdk_x11_display_ungrab            (GdkDisplay *display);
 
+GDK_AVAILABLE_IN_3_10
+void        gdk_x11_display_set_window_scale (GdkDisplay *display,
+                                              gint scale);
+
 GDK_AVAILABLE_IN_ALL
 void                           gdk_x11_display_error_trap_push        (GdkDisplay *display);
 /* warn unused because you could use pop_ignored otherwise */